<?php
$this->breadcrumbs=array(
	Yii::t('base','Equipments')=>array('admin'),
	Yii::t('base','Manage'),
);

$this->menu=array(
	array('label'=>'List Equipment', 'url'=>array('index')),
	array('label'=>'Create Equipment', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('equipment-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1><?php echo Yii::t('base','Manage Equipments');?></h1>

<?php echo CHtml::link(Yii::t('base','Advanced Search'),'#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
	'model'=>$model,
)); 
$user_id=yii::app()->request->getParam(user_id);
?>
</div><!-- search-form -->

<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'equipment-grid',
	'dataProvider'=>$model->search2($results),
	'itemsCssClass'=>'responsive table table-striped table-bordered',
	'pager'=>array('class'=>'CLinkPager','htmlOptions'=>array('class'=>'pagination pull-right')),
	'pagerCssClass'=>'pagination pull-right',
	'cssFile'=>false,
	'columns'=>array(
		array('name'=>'equipment_number','headerHtmlOptions'=>array('style'=>'width:20%')),
		array('name'=>'telephone_number','headerHtmlOptions'=>array('style'=>'width:20%')),
	//	array('name'=>'city','headerHtmlOptions'=>array('style'=>'width:10%')),
		array('name'=>'updater','headerHtmlOptions'=>array('style'=>'width:20%'),'value'=>'User::model()->findByPk($data->updater)->user_name'),
	//	array('name'=>'custom.deposit','value'=>'Equipment::model()->getDeposit($data->equipment_number)','headerHtmlOptions'=>array('style'=>'width:10%'),),
		array('name'=>'userservice.isreback','value'=>'Equipment::model()->getIsreback($data->equipment_number)','headerHtmlOptions'=>array('style'=>'width:20%')),	
		array(

		'class'=>'CButtonColumn',

		'header'=>Yii::t('base','Operate'),

		'updateButtonImageUrl'=>array('class'=>'gicon-edit'),

		'updateButtonOptions'=>array('class'=>'btn btn-small'),

		'deleteButtonImageUrl'=>array('class'=>'gicon-edit'),

		'deleteButtonOptions'=>array('class'=>'btn btn-inverse btn-small'),
		'template'=>'{Create Custom}{To Saled Customer}{Recreate Custom}',
		'buttons'=>array(
			'To Saled Customer'=>array(
		'label'=>Yii::t('base','To Saled Customer'),
		'url'=>'Yii::app()->createUrl("Custom/update",array("id"=>Equipment::model()->getcustomId($data->updater)))',
		'options'=>array('class'=>'btn btn-small'),
		'visible'=>'Equipment::model()->judgeB($data->equipment_number) && yii::app()->user->level!=1'
),
'Create Custom'=>array(
		'label'=>Yii::t('base','Create Custom'),
		'url'=>'Yii::app()->createUrl("Custom/agentcreate",array("equipment_number"=>$data->equipment_number,"user_id"=>yii::app()->request->getParam(user_id)))',
		'options'=>array('class'=>'btn btn-small'),
		'visible'=>'Equipment::model()->judgeA($data->equipment_number) && yii::app()->user->level!=1 && yii::app()->request->getParam("user_id")==yii::app()->user->id'
),
'Recreate Custom'=>array(
		'label'=>Yii::t('base','Recreate Custom'),
		'url'=>'Yii::app()->createUrl("Custom/agentcreate",array("equipment_number"=>$data->equipment_number,"user_id"=>yii::app()->request->getParam(user_id)))',
		'options'=>array('class'=>'btn btn-small'),
		'visible'=>'Equipment::model()->judgeC($data->equipment_number) && yii::app()->user->level!=1'
),

		),
),
	),
)); ?>
